<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jstl/fmt_rt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/pintuer.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/admin.css">
<script src="${pageContext.request.contextPath}/js/jquery.js"></script>
<script src="${pageContext.request.contextPath}/js/pintuer.js"></script>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/toastr.css">
<script src="${pageContext.request.contextPath}/js/toastr.min.js"></script>
</head>
<body>
	<script type="text/javascript">
	
    $(function() {
	   var prePage = ${info.prePage};
	   var nextPage = ${info.nextPage};
	   var firstPage = ${info.firstPage};
	   var lastPage = ${info.lastPage};
	$(".prePage").click(function() {
		if (prePage == 0) {
			toastr.options.positionClass = 'toast-center-center';
			toastr.error("当前已经是第一页了");
		} else {
			var url = "${pageContext.request.contextPath}/enterReaderManager?page="+prePage;
			submitForm(url);
		}
		return false;
	})
	$(".nextPage").click(function() {
		if ((prePage+1) == lastPage) {
			toastr.options.positionClass = 'toast-center-center'
			toastr.error("当前已经是最后一页了");
		} else {
			var url = "${pageContext.request.contextPath}/enterReaderManager?page="+nextPage;
			submitForm(url);
		}
		return false;
	})
	$(".endPage").click(function() {

		var url = "${pageContext.request.contextPath}/enterReaderManager?page="+lastPage;
		submitForm(url);
		return false;
	})
	
})
    function submitForm(actionUrl) {
	var formElement = document.getElementById("listform");
	formElement.action = actionUrl;
	formElement.submit();
    }
    function changesearch(){
		var url = "${pageContext.request.contextPath}/searchReader";
		submitForm(url);
	}

	</script>
	<script type="text/javascript">
		    function deleteReader(emId){
				if(confirm("你确定删除该用户信息吗?")){
					$.ajax({
						type:"POST",
						url:"${pageContext.request.contextPath}/deleteReader",
						data:{"user":emId},
						success:function(data){
							if(data.result=="删除成功"){
								toastr.options.positionClass = 'toast-center-center'
									toastr.success("删除成功,刷新页面生效");
							}
							else{
								toastr.options.positionClass = 'toast-center-center'
									toastr.error("删除失败");
							}
						}
						});
					return false;
				}	 
			}
		   
	</script>
	<form method="post" action="" id="listform">
		<div class="panel admin-panel">
			<div class="panel-head">
				<strong class="icon-reorder"> 读者列表</strong> <a href=""
					style="float: right; display: none;">添加字段</a>
			</div>
			<div class="padding border-bottom">
				<ul class="search" style="padding-left: 10px;">
					<li><input type="text" placeholder="请输入读者姓名搜索" name="readerName"
						class="input titleinput"
						style="width: 250px; line-height: 17px; display: inline-block" />
						<a href="javascript:void(0)"
						class="button border-main  icon-search" onclick="changesearch()">
							搜索</a></li>
				</ul>
			</div>
			<table class="table table-hover text-center">
				<tr class="trHeader">
					<th width="200" style="padding-left: 20px;">ID</th>
					<th width="100">姓名</th>
					<th width="100">性别</th>
					<th width="100">年龄</th>
					<th width="100">院校</th>
					<th width="100">手机号码</th>
					<th width="200">操作</th>
				</tr>
				<c:forEach items="${list}" var="msg">
					<tr class="tempTr">
						<td id="td"><c:out value="${msg.id}"></c:out></td>
						<td><c:out value="${msg.name}"></c:out></td>
						<td><c:out value="${msg.gender}"></c:out></td>
						<td><c:out value="${msg.age}"></c:out></td>
						<td><c:out value="${msg.colleage}"></c:out></td>
						<td><c:out value="${msg.phone}"></c:out></td>
						<td id="hello"><div class="button-group">
								<a style="margin-left: 15px;" class="button border-red"
									href="#" onclick="deleteReader('${msg.id}')"><span
									class="icon-trash-o"></span> 删除</a> 
				        </td>
					</tr>

				</c:forEach>

				<tr>
					<td colspan="8"><div class="pagelist">
							<button class="button border-main prePage"
								onclick="prePageClick()">上一页</button>
							&nbsp;&nbsp;&nbsp;
							<button class="button border-main nextPage"
								onclick="nextPageClick()">下一页</button>
							&nbsp;&nbsp;&nbsp;
							<button class="button border-main endPage">尾页</button>
						</div></td>
				</tr>


			</table>
		</div>
	</form>

</body>
</html>